<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:shiro="http://shiro.apache.org/tags">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.ListUploadsTitle}"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <p:layout fullPage="true">
                <p:layoutUnit position="north" size="90">
                    <h:panelGrid columns="3">
                        <p:graphicImage value="/resources/ikey.png" /> 
                        <table class="logintbl">
                            <tr>
                                <td><strong>Logged as:</strong>&nbsp;#{shiroLoginBean.username}&nbsp;|</td>
                                <td><h:form><h:commandLink action="#{logout.submit}" value="logout"/></h:form></td>
                            </tr>
                        </table>
                    </h:panelGrid>
                </p:layoutUnit>
                <p:layoutUnit position="west" size="200">
                    <p:panel header="Navigate">
                        <table border="0" class="teble">
                            <tr><td><p:commandLink styleClass="ui-icon ui-icon-folder-collapsed" action="/uploads/List"/></td><td><h:link outcome="/uploads/List" value="Uploads"/></td></tr>
                            <shiro:hasRole name="admin">
                                <tr><td><p:commandLink styleClass="ui-icon ui-icon-info" action="/userrole/List"/></td><td><h:link outcome="/faces/configs.xhtml" value="Server Status"/></td></tr>
                                <tr><td><p:commandLink styleClass="ui-icon ui-icon-person" action="/users/List"/></td><td><h:link outcome="/users/List" value="System Users"/></td></tr>
                            </shiro:hasRole>
                        </table>
                    </p:panel>
                </p:layoutUnit>
                <p:layoutUnit position="center">
                    <p:panel header="Document View">
                        <h:form styleClass="jsfcrud_list_form">
                            <h:panelGroup id="messagePanel" layout="block">
                                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                            </h:panelGroup>
                            <h:outputText escape="false" value="#{bundle.ListUploadsEmpty}" rendered="#{uploadsController.items.rowCount == 0}"/>
                            <h:panelGroup rendered="#{uploadsController.items.rowCount > 0}">
                                <h:outputText value="#{uploadsController.pagination.pageFirstItem + 1}..#{uploadsController.pagination.pageLastItem + 1}/#{uploadsController.pagination.itemsCount}"/>&nbsp;
                                <h:commandLink action="#{uploadsController.previous}" value="#{bundle.Previous} #{uploadsController.pagination.pageSize}" rendered="#{uploadsController.pagination.hasPreviousPage}"/>&nbsp;
                                <h:commandLink action="#{uploadsController.next}" value="#{bundle.Next} #{uploadsController.pagination.pageSize}" rendered="#{uploadsController.pagination.hasNextPage}"/>&nbsp;
                                <p:dataTable id="vrb" value="#{uploadsController.items}" var="item" style="border:solid 0px" paginator="true" rows="10" paginatorPosition="bottom"
                                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="#{bundle.ListUploadsTitle_id}"/>
                                        </f:facet>
                                        <h:outputText value="#{item.id}"/>
                                    </p:column>
                                    <p:column filterBy="#{item.document}" footerText="contains" filterMatchMode="contains">
                                        <f:facet name="header">
                                            <h:outputText value="#{bundle.ListUploadsTitle_document}"/>
                                        </f:facet>
                                        <h:outputText value="#{item.document}"/>
                                    </p:column>
                                    <p:column filterBy="#{item.uploadedby}" footerText="contains" filterMatchMode="contains">
                                        <f:facet name="header">
                                            <h:outputText value="#{bundle.ListUploadsTitle_uploadedby}"/>
                                        </f:facet>
                                        <h:outputText value="#{item.uploadedby}"/>
                                    </p:column>
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="#{bundle.ListUploadsTitle_uploaddate}"/>
                                        </f:facet>
                                        <h:outputText value="#{item.uploaddate}">
                                            <f:convertDateTime pattern="MM/dd/yyyy" />
                                        </h:outputText>
                                    </p:column>
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="&nbsp;"/>
                                        </f:facet>
                                        <h:commandLink action="#{uploadsController.prepareView}" value="#{bundle.ListUploadsViewLink}"/>
                                        <h:outputText value=" "/>
                                        <h:commandLink action="#{uploadsController.prepareEdit}" value="#{bundle.ListUploadsEditLink}"/>
                                        <h:outputText value=" "/>
                                        <shiro:hasRole name="admin">
                                            <h:commandLink action="#{uploadsController.destroy}" value="#{bundle.ListUploadsDestroyLink}"/>
                                            <h:outputText value=" "/>
                                        </shiro:hasRole>
                                        <h:commandLink id="down" action="#{uploadsController.prepareDownload}" value="Download File"/>  
                                        <p:tooltip for="down" value="Download File" /><h:outputText value=" "/>
                                    </p:column>
                                </p:dataTable>
                            </h:panelGroup>
                            <table>
                                <tr><td><h:commandLink action="#{uploadsController.prepareCreate}" value="#{bundle.ListUploadsCreateLink}"/>&nbsp;|</td>
                                    <shiro:hasRole name="admin">
                                        <td><h:link id="ho" outcome="/index" value="#{bundle.ListUploadsIndexLink}"/></td>
                                        <td>|</td>
                                        <td>
                                            <h:commandLink id="exp1">  
                                                <p:graphicImage value="/resources/excel.png"/>  
                                                <p:dataExporter type="xls" target="vrb" fileName="uploadlist"/>  
                                                <p:tooltip for="exp1" value="Export as Excel"/>
                                            </h:commandLink>
                                        </td>                
                                        <p:tooltip for="ho" value="Home" />
                                    </shiro:hasRole>
                                </tr>
                            </table> 
                        </h:form>
                    </p:panel>
                </p:layoutUnit>
            </p:layout>
        </ui:define>
    </ui:composition>
</html>
